﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Media.Imaging;
using System.IO;
using System.Reflection;

namespace RobotEscape
{
    public static class Util
    {
        static FontSource fontSource = null;

        public static void DrawText(WriteableBitmap wb, string text, double fontSize, int x, int y, Color color, TextAlignment align = TextAlignment.Left, bool bold = false)
        {
            if (fontSource == null)
            {
                Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RobotEscape.Assets.fonts.NovaSquare.ttf");
                fontSource = new FontSource(stream);
            }
            TextBlock txt1 = new TextBlock();
            txt1.FontSource = fontSource;
            txt1.FontFamily = new FontFamily("NovaSquare");
            if (bold)
                txt1.FontWeight = FontWeights.Bold;
            
            txt1.Text = text;
            txt1.FontSize = fontSize; // set the font size before using the Actual Width / Height

            txt1.Foreground = new SolidColorBrush(color);
            if (align == TextAlignment.Right)
                x = x - (int)txt1.ActualWidth;
            if (align == TextAlignment.Center)
                x = x - (int)txt1.ActualWidth / 2;
            wb.Render(txt1, new TranslateTransform() { X = x, Y = y });
        }

        public static Color BackgroundGrey
        {
            get
            {
                return Color.FromArgb(220, 27, 27, 27);
            }
        }
        public static Color RobotRed
        {
            get
            {
                return Color.FromArgb(255, 190, 20, 20);
            }
        }
    }
}
